Magnetic sensor

ABSTRACT

A magnetic sensor is provided that can attenuate a magnetic field in a direction that is perpendicular to the magnetic field detecting direction at a higher rate than the magnetic field in the magnetic field detecting direction. 
     Magnetic sensor  1  has: first soft magnetic layer  3 ; a pair of second soft magnetic layers  4 A,  4 B that is positioned at a location that is different from first soft magnetic layer  3  in the Z direction of first soft magnetic layer  3 ; and magnetic field detecting element  2  that is positioned between first soft magnetic layer  3  and second soft magnetic layers  4 A,  4 B in the Z direction, wherein magnetic field detecting element  2  has a magnetic field detecting direction that is parallel to a direction in which the pair of second soft magnetic layers  4 A,  4 B is arranged. As viewed in the Z direction, second soft magnetic layers  4 A,  4 B are positioned on both sides of a center of first soft magnetic layer  3 , and magnetic field detecting element  2  is positioned inside of a periphery of first soft magnetic layer  3.

FIELD OF THE INVENTION

The present application is based on, and claims priority from, JPApplication No. 2019-193474, filed on Oct. 24, 2019, the disclosure ofwhich is hereby incorporated by reference herein in its entirety.

The present invention relates to a magnetic sensor.

BACKGROUND OF THE INVENTION

A magnetic sensor detects a magnetic field in a specific direction (amagnetic field detecting direction). A magnetic sensor has a magneticfield detecting element. Since a magnetic field detecting element thatuses magnetoresistive effect, which is typically a TMR element, ishighly likely to be magnetically saturated when a large magnetic fieldis detected, a shield structure for attenuating the magnetic field maybe provided in the vicinity of the magnetic field detecting element. JP2017-502298 discloses a magnetic sensor in which attenuators areprovided in the vicinity of detecting elements and in which shields areprovided in the vicinity of reference elements. The attenuators and theshields are formed of a soft magnetic material etc., and are alternatelyarranged in the magnetic field detecting direction on the same plane.The detecting elements are provided immediately below the attenuators,and the reference elements are provided immediately below the shields.That is, the detecting elements and the reference elements are providedon the same side of the attenuators and the shields.

SUMMARY OF THE INVENTION

It is desired that a magnetic sensor only detect a magnetic field in themagnetic field detecting direction, but an external magnetic fieldusually contains components in directions other than the magnetic fielddetecting direction. Components of a magnetic field in directions otherthan the magnetic field detecting direction are a source of noise forthe magnetic sensor and reduce the S/N ratio. The magnetic sensor thatis described in JP 2017-502298 can attenuate a magnetic field in themagnetic field detecting direction, but JP 2017-502298 is silent about amagnetic field in a direction that is perpendicular to the magneticfield detecting direction.

The present invention aims at providing a magnetic sensor that canattenuate a magnetic field in a direction that is perpendicular to themagnetic field detecting direction at a higher rate than the magneticfield in the magnetic field detecting direction.

A magnetic sensor of the present invention comprises: a first softmagnetic layer; a pair of second soft magnetic layers that is positionedat a location that is different from the first soft magnetic layer in athickness direction of the first soft magnetic layer; and a magneticfield detecting element that is positioned between the first softmagnetic layer and the second soft magnetic layers in the thicknessdirection; wherein the magnetic field detecting element has a magneticfield detecting direction that is parallel to a direction in which thepair of the second soft magnetic layers is arranged. As viewed in thethickness direction; the second soft magnetic layers are positioned onboth sides of a center of the first soft magnetic layer; and themagnetic field detecting element is positioned inside of a periphery ofthe first soft magnetic layer.

According to the present invention, it is possible to provide a magneticsensor that can attenuate a magnetic field in a direction that isperpendicular to the magnetic field detecting direction at a higher ratethan the magnetic field in the magnetic field detecting direction.

The above and other objects, features and advantages of the presentinvention will become apparent from the following description withreference to the accompanying drawings which illustrate examples of thepresent invention.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1A is a conceptual perspective view of a magnetic sensor accordingto a first embodiment;

FIG. 1B is a sectional view taken along line A-A in FIG. 1A;

FIGS. 2A and 2B are examples of magnetic flux density when an externalmagnetic field is applied to the magnetic sensor shown in FIG. 1A;

FIG. 3A is a conceptual perspective view of a magnetic sensor accordingto a second embodiment;

FIG. 3B is a sectional view taken along line A-A in FIG. 3A;

FIG. 4A is a conceptual plan view of the magnetic sensor according tothe second embodiment;

FIG. 4B is a diagram showing the conceptual circuit configuration of amagnetic sensor that corresponds to FIG. 4A;

FIGS. 5A and 5B are examples of magnetic flux density when an externalmagnetic field is applied to the magnetic sensor shown in FIG. 4A;

FIG. 6A a conceptual perspective view of a magnetic sensor according toa third embodiment;

FIG. 6B is a sectional view taken along line A-A in FIG. 6A; and

FIG. 7 is an example of magnetic flux density when an external magneticfield is applied to the magnetic sensor shown in FIG. 6A.

DETAILED DESCRIPTION OF THE EMBODIMENTS

Hereinafter, some embodiments of the magnetic sensor of the presentinvention will be described with reference to the drawings. In thefollowing descriptions and the drawings, the X direction is a directionthat is parallel to the magnetic field detecting direction of themagnetic sensor, or a direction that is parallel to the direction inwhich a pair of second soft magnetic layers is arranged. The Y directionis a direction that is parallel to the edges of the second soft magneticlayers, wherein the edges face each other. The Y direction correspondsto the direction of a biasing magnetic field for the magnetic fielddetecting element. The Z direction is a direction that is perpendicularboth to the X direction and to the Y direction, and corresponds to thethickness direction of the first soft magnetic layer, the second softmagnetic layers and the magnetic field detecting element. A magneticfield in the X direction is a signal magnetic field, and a magneticfield in the Y direction is a magnetic field that is to be blocked.

First Embodiment

FIGS. 1A, 1B are conceptual views of magnetic sensor 1 according to thefirst embodiment, wherein FIG. 1A shows a perspective view of magneticsensor 1, and FIG. 1B shows a cross sectional view taken along line A-Ain FIG. 1A. Magnetic sensor 1 includes magnetic field detecting element2, first soft magnetic layer 3 and a pair of second soft magnetic layers4A, 4B. Magnetic field detecting element 2 is composed of a plurality ofTMR elements (not illustrated) that are connected in series. When noexternal magnetic field is present, the magnetization direction of thefree layer of each TMR element is directed in the Y direction by a biasmagnet (not illustrated). When an external magnetic field (a signalmagnetic field) is applied in the X direction, the magnetizationdirection of the free layer rotates toward the X direction in the X-Yplane depending on the intensity of the external magnetic field, and theelectric resistance of the TMR element is changed. Magnetic sensor 1outputs a voltage that corresponds to the electric resistance, andthereby the intensity of the magnetic field in the X direction isdetermined.

First soft magnetic layer 3 is a thin film made of a soft magneticlayer, such as perm-alloy (NiFe), and is formed by plating orsputtering. As viewed in the Z direction, first soft magnetic layer 3 isrectangular, and magnetic field detecting element 2 is contained infirst soft magnetic layer 3. In other words, as viewed in the Zdirection, magnetic field detecting element 2 is positioned inside ofperiphery 31 of first soft magnetic layer 3, and periphery 21 ofmagnetic field detecting element 2 does not overlap periphery 31 offirst soft magnetic layer 3. The shape of first soft magnetic layer 3,as viewed in the Z direction, may be determined depending on the shapeof magnetic field detecting element 2. For example, if magnetic fielddetecting element 2 has a shape of a bar that is elongate in the Ydirection, then first soft magnetic layer 3 may also have a shape of abar that is elongate in the Y direction. Gap G1 is provided betweenfirst soft magnetic layer 3 and magnetic field detecting element 2 inthe Z direction.

A pair of second soft magnetic layers 4A, 4B is positioned at a locationor a level that is different from that of first soft magnetic layer 3 inthe Z direction. Second soft magnetic layers 4A, 4B are provided at thesame level in the Z direction. That is, gap G2 is provided between firstsoft magnetic layer 3 and a pair of second soft magnetic layers 4A, 4Bin the Z direction. Magnetic field detecting element 2 is providedbetween first soft magnetic layer 3 and second soft magnetic layers 4A,4B in the Z direction. Thus, first soft magnetic layer 3, magnetic fielddetecting element 2 and a pair of second soft magnetic layers 4A, 4Bconstitute a three-layered structure, in which these are separated fromeach other in the Z direction. The space between first soft magneticlayer 3 and magnetic field detecting element 2 and the space betweenmagnetic field detecting element 2 and a pair of second soft magneticlayers 4A, 4B are filled with a non-magnetic material, such as alumina.As viewed in the Z direction (that is, in the X direction), second softmagnetic layer 4A and second soft magnetic layer 4B are positioned onboth sides of center C of first soft magnetic layer 3 in the X directionand overlap first soft magnetic layer 3. As viewed in the Z direction(that is, in the X direction), magnetic field detecting element 2 ispositioned between second soft magnetic layer 4A and second softmagnetic layer 4B, and is spaced both from second soft magnetic layer 4Aand from second soft magnetic layer 4B.

FIG. 2A shows magnetic flux density (Bx) when an external magnetic fieldhaving magnetic flux density of 10 mT is applied in the X direction, andFIG. 2B shows magnetic flux density (By) when an external magnetic fieldhaving magnetic flux density of 10 mT is applied in the Y direction.Example corresponds to the present embodiment, while only first softmagnetic layer 3 is provided in Comparative Example 1, and only a pairof second soft magnetic layers 4A, 4B is provided in Comparative Example2. Bx and By are average values in the thickness direction (the Zdirection) where magnetic field detecting element 2 is arranged, and thearea of magnetic field detecting element 2 in the X direction isdepicted in the drawing. In Comparative Example 1, both Bx and By aresmall in the area of magnetic field detecting element 2. This means thatfirst soft magnetic layer 3 functions as a shield that weakens amagnetic field. In Comparative Example 2, both Bx and By are large inthe area of magnetic field detecting element 2. This means that secondsoft magnetic layers 4A, 4B function as yolks that enhance the magneticfield. Table 1 shows Py/Px, which is the ratio of magnetic fieldtransmittance Py in the Y direction to magnetic field transmittance Pxin the X direction. Magnetic field transmittance Px, Py is defined asthe ratio of “the magnetic flux density where the magnetic fieldtransmittance is determined” to “the magnetic flux density that would begenerated by an external magnetic field if first soft magnetic layer 3and second soft magnetic layers 4A, 4B were not provided”. The rate atwhich Comparative Example 2 increases relative to Comparative Example 1is greater in the X direction than in the Y direction. Therefore, Py/Pxis smaller in Comparative Example 2 than in Comparative Example 1.Example shows a larger magnetic flux density Bx than Comparative Example1 in the area of magnetic field detecting element 2. In contrast,magnetic flux density By is almost the same as Comparative Example 1. Asa result, Py/Px is smaller than that of Comparative Example 2,Accordingly, Example has a good performance of transmitting a signalmagnetic field and of attenuating a magnetic field that is perpendicularto the signal magnetic field, and is resistive to a disturbing magneticfield that is applied from a direction different from the direction inwhich a signal magnetic field is applied. In addition, since ComparativeExample 2 shows large values both for Bx and for By, when a largeexternal magnetic field is applied, the output of magnetic sensor 1 maybe saturated and the measurement accuracy may be lowered.

TABLE 1 Magnetic field Magnetic field transmittance in the transmittancein the X direction Px (%) Y direction Px (%) Py/Px Comparative Firstsoft magnetic 6.68 5.37 0.80 Example 1 layer only Comparative Secondsoft magnetic 176.04 61.77 0.35 Example 2 layers only Example First softmagnetic 36.53 5.40 0.15 layer and second magnetic layers

Tables 2 and 3 show magnetic field transmittance Px in the X direction,magnetic field transmittance Py in the Y direction and ratio Py/Px,wherein overlapping length D (See FIG. 1B) between first soft magneticlayer 3 and second soft magnetic layers 4A, 4B, as viewed in the Zdirection, is taken as a parameter. Magnetic field transmittance Px inthe X direction is the value when an external magnetic field of 10 mT isapplied in the X direction, and magnetic field transmittance Py in the Ydirection is the value when an external magnetic field of 10 mT isapplied in the Y direction. When D is negative, first soft magneticlayer 3 does not overlap second soft magnetic layers 4A, 4B, and thespace between first soft magnetic layer 3 and second soft magneticlayers 4A, 4B is indicated by the negative value of D. Table 2 showswhere width W of second soft magnetic layers 4A, 4B (See FIG. 1B) is 12μm, and Table 3 shows where width W of soft magnetic layers 4A, 4B is 24μm.

TABLE 2 Overlapping length D (μm) 6 4 2 0 −2 −4 Px 8.0 8.5 8.0 7.7 7.67.3 Py 4.9 5.7 5.7 5.1 5.0 4.9 Py/Px 0.62 0.67 0.72 0.66 0.66 0.68

TABLE 3 Overlapping length D (μm) 8 4 0 −4 Px 9.1 8.4 7.6 7.4 Py 4.5 4.84.4 4.5 Py/Px 0.50 0.57 0.58 0.61

As can be understood from Tables 2 and 3, whether or not overlap ispresent, and the magnitude of overlapping length D, do not make asignificant difference in Py/Px, and may be appropriately chosendepending on other factors. Thus, a pair of second soft magnetic layers4A, 4B may be spaced from first soft magnetic layer 3, as viewed in theZ direction. For example, the dimension of magnetic sensor 1 in the Xdirection can be shortened by increasing overlapping length D betweenfirst soft magnetic layer 3 and second soft magnetic layers 4A, 4B. Iffirst soft magnetic layer 3 does not overlap second soft magnetic layers4A, 4B, then a large area having small Bx will be secured on first softmagnetic layer 3, so that the area of magnetic field detecting element 2will be increased in the X direction.

Second Embodiment

FIGS. 3A, 3B are conceptual views of magnetic sensor 1 according to thesecond embodiment, wherein FIG. 3A shows a perspective view of magneticsensor 1, and FIG. 3B shows a cross sectional view taken along line A-Ain FIG. 3A. In the present embodiment, four magnetic field detectingelements (first to fourth magnetic field detecting elements 2A to 2D)are provided. FIG. 4A is a plan view of magnetic sensor 1, and FIG. 4Bshows a conceptual circuit configuration of magnetic sensor 1 thatcorresponds to FIG. 4A. Magnetic field detecting elements 2A to 2D areinterconnected in a bridge circuit (Wheatstone bridge), Four magneticfield detecting elements 2A to 2D are divided into two sets, that is,set 2A, 2B and set 20, 2D. Magnetic field detecting element 2A and 2B ofthe set are connected in series, and magnetic field detecting elements2C and 2D of the set are connected in series. One end of set 2A, 2B ofthe magnetic field detecting elements and one end of set 2C, 2D of themagnetic field detecting elements are connected to supply voltage Vcc,and the other ends are grounded (GND). Further, midpoint voltage V1between first magnetic field detecting element 2A and second magneticfield detecting element 2B and midpoint voltage V2 between thirdmagnetic field detecting element 2C and fourth magnetic field detectingelement 2D are outputted. Therefore, midpoint voltages V1, V2 aredetermined as follows, where electric resistance of first to fourthmagnetic field detecting elements 2A to 20 are R1 to R4, respectively.

$\begin{matrix}{V_{1} = {\frac{R_{2}}{R_{1} + R_{2}}V_{cc}}} & ( {{Formula}\mspace{14mu} 1} ) \\{V_{2} = {\frac{R_{3}}{R_{3} + R_{4}}V_{cc}}} & ( {{Formula}\mspace{14mu} 2} )\end{matrix}$

By detecting difference V1−V2 between midpoint voltages V1 and V2, thesensitivity can be doubled as compared to detecting midpoint voltage V1and V2. In addition, even when midpoint voltages V1, V2 are offset, theinfluence of the offset can be eliminated by detecting the difference.

Magnetic sensor 1 of the present embodiment has a plurality of sets 5Ato 5D, each comprising a magnetic field detecting element, a first softmagnetic layer and a pair of second soft magnetic layers. First set 5Aincludes magnetic field detecting element 2A, first soft magnetic layer3A and a pair of second soft magnetic layers 4A, 4B. Second set 5Bincludes magnetic field detecting element 2B, first soft magnetic layer3B and a pair of second soft magnetic layers 4B, 40, Third set 5Cincludes magnetic field detecting element 2C, first soft magnetic layer3C and a pair of second soft magnetic layers 4D, 4E. Fourth set 5Dincludes magnetic field detecting element 2D, first soft magnetic layer3D, and a pair of second soft magnetic layers 4E, 4F. First set 5A andsecond set 5B are adjacent to each other in the magnetic field detectingdirection X so as to form first row 6A, and third set 5C and fourth set5D are adjacent to each other in the magnetic field detecting directionX so as to form second row 6B. First row 6A and second row 6B areadjacent to each other in the Y direction that is perpendicular to themagnetic field detecting direction. Second soft magnetic layer 4B, whichis one of the elements of first set 5A, is integral with second softmagnetic layer 4B, which is one of the elements of adjacent second set5B. Similarly, second soft magnetic layer 4E, which is one of theelements of third set 50, is integral with second soft magnetic layer4E, which is one of the elements of adjacent fourth set 5D.

FIG. 5A shows magnetic flux density (Bx) when external magnetic fieldshaving magnetic flux density of 10 mT and 100 mT are applied in the Xdirection, and FIG. 5B shows magnetic flux density (By) when externalmagnetic fields having magnetic flux density of 10 mT and 100 mT areapplied in the Y direction. Bx and By are average values in thethickness direction (the Z direction) where magnetic field detectingelements 2A to 2D are arranged. Bx is large and By is small in the areaof magnetic field detecting elements 2A to 2D. Both in the case of 10 mTand in the case of 100 mT, magnetic field transmittance Px in the Xdirection was 23%, magnetic field transmittance Py in the Y directionwas 4%, and Py/Px was about 17%.

As viewed in the Z direction, centers C1 of magnetic field detectingelements 2A, 2B, 2C and 2D and centers C2 of second soft magnetic layers4A to 4F of the sets are closer to boundary B between first row 6A andsecond row 6B than to centers C3 of first soft magnetic layers 3A, 3B,3C and 3D, respectively. This makes it possible to limit the variationin Bx in the area of magnetic field detecting elements 2A to 2D. Thevariation in Bx in the area of magnetic field detecting elements 2A to2D leads to variation in the outputs of MR elements that constitutemagnetic field detecting elements 2A to 2D. As a result, the output ofmagnetic field detecting elements 2A to 2D are more likely to beaffected by edges 7. The degree of freedom in designing magnetic fielddetecting elements 2A to 2D can be increased by limiting the variation.

Third Embodiment

FIGS. 6A, 6B are conceptual views of magnetic sensor 1 according to thethird embodiment, wherein FIG. 6A shows a perspective view of magneticsensor 1, and FIG. 6B shows a cross sectional view taken along line A-Ain FIG. 6A. The present embodiment is a modification of the secondembodiment, but may also be applied to the first embodiment. Edges 7 ofsecond soft magnetic layers 4A to 4F that face first soft magneticlayers 3 are chamfered. FIG. 7 shows magnetic flux density (Bx) when anexternal magnetic field having magnetic flux density of 10 mT is appliedin the X direction. When no chamfer is formed, peaks of Bx are observednear the ends of the area of magnetic field detecting element 2 in the Xdirection (substantially corresponds to edges 7 of second soft magneticlayers 4A to 4F). Since magnetic flux concentrates at sharp edges 7,magnetic flux density increases in the vicinity of the edges. As aresult, the magnitude of Bx varies in the area of magnetic fielddetecting elements 2A to 2D. Chamfering edges 7 reduces the magneticflux density at edges 7 of second soft magnetic layers 4A to 4F, asillustrated, and further levels the magnitude of Bx in the area ofmagnetic field detecting elements 2A to 2D. As a result, the effectsthat are mentioned in the second embodiment are further enhanced.

As described above, in each embodiment mentioned above, first softmagnetic layer 3 (or 3A to 3D) and second soft magnetic layers 4A, 4B(or 4A to 4F) are arranged at different levels. This increases theflexibility in the arrangement of first soft magnetic layer 3 and secondsoft magnetic layers 4A, 4B. For example, by adjusting overlappinglength D in the X direction between first soft magnetic layer 3 andsecond soft magnetic layers 4A, 4B or by adjusting dimension H of gap G2in the Z direction between first soft magnetic layer 3 and second softmagnetic layers 4A, 4B (see FIG. 1B), the performance of collectingmagnetic flux of second soft magnetic layers 4A, 4B, that function asyolks, can be adjusted. Table 4 shows average magnetic fieldtransmittance in the X direction for various dimensions H of gap G2 inthe area of magnetic field detecting element 2. Gap G1 between magneticfield detecting element 2 and first soft magnetic layer 3 is 1 μm. Theaverage magnetic field transmittance can be adjusted by changingdimension H of gap G2. In general, the sensitivity of magnetic sensor 1increases in accordance with the increase in the average magnetic fieldtransmittance, but the signal magnetic field may conversely have to bereduced when the signal magnetic field is large. Thus, in eachembodiment mentioned above, it is easy to adjust the average magneticfield transmittance.

TABLE 4 Dimension H of gap G2 (μm) 1 2 3 Average magnetic fieldtransmittance (%) 11.9 13.6 14.2

In each embodiment mentioned above, one first soft magnetic layer 3 iscombined with one magnetic field detecting element 2. First softmagnetic layer 3 is sized to cover magnetic field detecting element 2,as viewed in the Z direction, and is less affected by manufacturingerrors. Therefore, the yield of magnetic sensor 1 can be improved. Sincethe shape of first soft magnetic layer 3 is not particularly limited, itis possible to employ first soft magnetic layer 3 having optimum shapeand size that match the design of magnetic field detecting element 2.

The shape of second soft magnetic layers 4A, 4B is not limited, either.For example, when second soft magnetic layers 4A, 4B are elongate in theY direction, the magnetization of second soft magnetic layers 4A, 4Btends to be saturated in the Y direction. Since the aspect ratio ofsecond soft magnetic layers 4A, 4B, as viewed in the Z direction, is notlimited in the present embodiments, it is possible to employ second softmagnetic layers 4A, 4B having an optimum shape.

The present invention is not limited to the above-mentioned embodiments.For example, magnetic field detecting element 2 may overlap either orboth of second soft magnetic layers 4A, 4B, as viewed in the Zdirection. In the second and third embodiments, four magnetic fielddetecting elements 2 that constitute a bridge circuit may be arranged ina row. In other words, at least some of sets 5A to 5D may are adjacentto each other in the magnetic field detecting direction.

Although certain preferred embodiments of the present invention havebeen shown and described in detail, it should be understood that variouschanges and modifications may be made without departing from the spiritor scope of the appended claims.

What is claimed is:
 1. A magnetic sensor comprising: a first softmagnetic layer, a pair of second soft magnetic layers that is positionedat a location that is different from the first soft magnetic layer in athickness direction of the first soft magnetic layer, a magnetic fielddetecting element that is positioned between the first soft magneticlayer and the second soft magnetic layers in the thickness direction,wherein the magnetic field detecting element has a magnetic fielddetecting direction that is parallel to a direction in which the pair ofthe second soft magnetic layers is arranged, wherein as viewed in thethickness direction, the second soft magnetic layers are positioned onboth sides of a center of the first soft magnetic layer, and themagnetic field detecting element is positioned inside of a periphery ofthe first soft magnetic layer.
 2. The magnetic sensor according to claim1, wherein at least a part of the magnetic field detecting element ispositioned between the second soft magnetic layers, as viewed in thethickness direction.
 3. The magnetic sensor according to claim 1,wherein the pair of the second soft magnetic layers overlaps the firstsoft magnetic layer, as viewed in the thickness direction.
 4. Themagnetic sensor according to claim 1, wherein the pair of the secondsoft magnetic layers is spaced from the first soft magnetic layer, asviewed in the thickness direction.
 5. The magnetic sensor according toclaim 1, wherein an edge of the second soft magnetic layer that facesthe first soft magnetic layer is chamfered.
 6. The magnetic sensoraccording to claim 1, further comprising a plurality of sets, whereineach set comprises the magnetic field detecting element the first softmagnetic layer and the pair of second soft magnetic layers, and themagnetic field detecting elements of the sets constitute a bridgecircuit, and at least some of the sets are adjacent to each other in themagnetic field detecting direction, and one of the second soft magneticlayers of one of adjacent sets is integral with one of the second softmagnetic layers of the remaining adjacent set.
 7. The magnetic sensoraccording to claim 6, wherein the plurality of sets is four sets,wherein two of the four sets are adjacent to each other in the magneticfield detecting direction so as to form a first row, and remaining twoof the four sets are adjacent to each other in the magnetic fielddetecting direction so as to form a second row, the first row and thesecond row are adjacent to each other in a direction that isperpendicular to the magnetic field detecting direction, and a center ofthe magnetic field detecting element and centers of the second softmagnetic layers of each set are closer to a boundary between the firstrow and the second row than a center of the first soft magnetic layer,as viewed in the thickness direction.
 8. The magnetic sensor accordingto claim 1, wherein the magnetic field detecting element has a TMRelement.